#include <iostream>
using namespace std;
const int N = 300;
int x[N], y[N];
int cnta, cntb;
int check(int a, int b) {
    if(a == b) {
        return 0;
    }
    if(((a < 4 && b < 4&& a < b && abs(a - b) == 1)) || (a == 2 && b == 0) || (a == 1 && b == 4) || (a == 0 && b == 4)|| (a == 3 && b < 2) || (a == 4 && b == 2) || (a == 4 && b == 3))
        return -1;
    else  {
        return 1;
    }
}
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 0; i < a; i++) {
        cin >> x[i];
    }
    for(int j = 0; j < b; j++) {
        cin >> y[j];
    }
    for(int i = 0; i < n; i++) {
        int t = check(x[(i + a) % a], y[(i + b) % b]);
        if( t > 0) {
            cnta++;
        }else if(t == 0){
        }else {
            cntb++;
        }
        
    }
    cout << cnta << " " << cntb <<endl;
    return 0;
}

/*

#include <iostream>
using namespace std;

const int N = 300;
int x[N], y[N];
int cnta = 0, cntb = 0;

int win[5][5] = {
    { 0 , -1 , 1 , 1 , -1 },
    { 1 ,  0 , -1 , 1 , -1 },
    { -1 , 1 , 0 , -1 , 1 },
    { -1 , -1 , 1 , 0 , 1 },
    { 1 , 1 , -1 , -1 , 0 }
};

int check(int a, int b) {
    return win[a][b];
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 0; i < a; i++) {
        cin >> x[i];
    }
    for(int j = 0; j < b; j++) {
        cin >> y[j];
    }
    for(int i = 0; i < n; i++) {
        int t = check(x[i % a], y[i % b]);
        if(t > 0) cnta++;
        else if(t < 0) cntb++;
    }
    cout << cnta << " " << cntb << endl;
    return 0;
}

*/